<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="../../../static/css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../../static/js/jquery.js"></script>
</head>

<body>
<div class="place"><span>位置：</span>
    <ul class="placeul">
        <li>营销管理</li>
        <li>订购单管理</li>
        <li>订购单详情</li>
    </ul>
</div>
<div class="formbody">
    <div class="formtitle"><span>订购单信息</span></div>
    <ul class="forminfo" id="forminfo">
        <li>
            <label>订单编号</label>
            <cite>DJ201711180001</cite>
        </li>
        <li>
            <label>客户姓名</label>
            <cite><a href="../../market/customer/customerView.html" title="点击查看客户详细信息" class="tablelink">王金平</a></cite>
        </li>
        <li>
            <label>联系电话</label>
            <cite>17370899727</cite>
        </li>
        <li>
            <label>订购时间</label>
            <cite>2017-11-18 15:36:10</cite>
        </li>
        <li>
            <label>总金额</label>
            <cite>￥9,876,582</cite>
        </li>
        <li>
            <label>操作人</label>
            <cite>关羽</cite>
        </li>
        <li>
            <label>审核状态</label>
            <cite>已审核通过</cite>
        </li>
        <li>
            <label>审核意见</label>
            <cite>做的很详细，同意通过</cite>
        </li>
        <li>
            <label>审核人</label>
            <cite>曹操</cite>
        </li>
        <li>
            <label>审核时间</label>
            <cite>2017-01-30 12:05:05</cite>
        </li>
        <li>
            <label>出货仓库</label>
            <cite><a href="../storage/storageView.html" title="点击查看客户详细信息" class="tablelink">南京21号仓库</a></cite>
        </li>
        <li>
            <label>出库时间</label>
            <cite>2013-09-09 15:05:05</cite>
        </li>
        <li>
            <label>出库人</label>
            <cite>朱元璋</cite>
        </li>
        <li>
            <label>出库状态</label>
            <cite>已回款</cite>
        </li>
    </ul>
    <table class="tablelist">
        <thead>
        <tr>
            <th>序号</th>
            <th>品牌</th>
            <th>类型</th>
            <th>型号</th>
            <th>数量</th>
            <th>单位</th>
            <th>单价</th>
            <th>金额</th>
        </tr>
        </thead>
        <tbody id="orderView">
        <tr>
            <td>1</td>
            <td>联想</td>
            <td>笔记本电脑</td>
            <td>T470</td>
            <td>10</td>
            <td>台</td>
            <td>9998</td>
            <td>99980</td>
        </tr>
        </tbody>
    </table>
    <div style="margin-top:20px; margin-left:20px;">
        <!--    <a href="/ckWarehouse/lists">-->
        <input onclick="window.history.go(-1);" name="" type="button" class="btn" value="返回"/>
        <!--    </a>-->
    </div>
</div>
<script type="text/javascript">

    $('.tablelist tbody tr:odd').addClass('odd');

    $(function () {
        var orderid = getParameter("orderid");
        queryOrderView(orderid);
    })

    function queryOrderView(orderid) {
        $.ajax({
            url: "/sales/custom",
            method: "post",
            dataType: "json",
            data: {orderid: orderid},
            success: function (data1) {
                console.log(data1);
                $.ajax({
                    url: "/sales/orders",
                    method: "post",
                    dataType: "json",
                    data: {orderid: orderid},
                    success: function (data2) {
                        console.log(data2);
                        let da1 = data1.data.data[0];
                        let da2 = data2.data.data[0];
                        var total = 0;
                        for (var j = 0; j < da2.orderDetailsList.length; j++) {
                            total += da2.orderDetailsList[j].prototal;
                        }
                        let sta = '';
                        if (da2.status == "1") {
                            sta = '未审核';
                        }
                        if (da2.status == "2") {
                            sta = '审核中';
                        }
                        if (da2.status == "3") {
                            sta = '审核通过';
                        }
                        if (da2.status == "4") {
                            sta = '审核不通过';
                        }

                        let sta2 = '';
                        if (da2.ckWarehouse.state == "1") {
                            sta2 = '未发货';
                        }
                        if (da2.ckWarehouse.state == "2") {
                            sta2 = '已发货';
                        }
                        if (da2.ckWarehouse.state == "3") {
                            sta2 = '已回款';
                        }
                        if (da2.ckWarehouse.state == "4") {
                            sta2 = '取消订单';
                        }
                        if (da2.ckWarehouse.state == "5") {
                            sta2 = '已退货';
                        }

                        let str1 = '';
                        str1 += '<li>\n' +
                            '            <label>订单编号</label>\n' +
                            '            <cite>' + da2.orderid + '</cite>\n' +
                            '        </li>\n' +
                            '        <li>\n' +
                            '            <label>客户姓名</label>\n' +
                            '            <cite><a href="../../market/customer/customerView?customid=' + da1.customid + '" title="点击查看客户详细信息" class="tablelink">' + da2.customname + '</a></cite>\n' +
                            '        </li>\n' +
                            '        <li>\n' +
                            '            <label>联系电话</label>\n' +
                            '            <cite>' + da1.telephone + '</cite>\n' +
                            '        </li>\n' +
                            '        <li>\n' +
                            '            <label>订购时间</label>\n' +
                            '            <cite>' + da2.ordertime + '</cite>\n' +
                            '        </li>\n' +
                            '        <li>\n' +
                            '            <label>总金额</label>\n' +
                            '            <cite>￥' + total + '</cite>\n' +
                            '        </li>\n' +
                            '        <li>\n' +
                            '            <label>操作人</label>\n' +
                            '            <cite>' + da2.operatorusers.uname + '</cite>\n' +
                            '        </li>\n' +
                            '        <li>\n' +
                            '            <label>审核状态</label>\n' +
                            '            <cite>' + sta + '</cite>\n' +
                            '        </li>\n' +
                            '        <li>\n' +
                            '            <label>审核意见</label>\n' +
                            '            <cite>' + da2.opinion + '</cite>\n' +
                            '        </li>\n' +
                            '        <li>\n' +
                            '            <label>审核人</label>\n' +
                            '            <cite>' + da2.checkusers.uname + '</cite>\n' +
                            '        </li>\n' +
                            '        <li>\n' +
                            '            <label>审核时间</label>\n' +
                            '            <cite>' + da2.chectime + '</cite>\n' +
                            '        </li>\n' +
                            '        <li>\n' +
                            '      <label>出货仓库</label>\n' +
                            '      <cite><a href="/storage/storage/storageView?WarehouseID=' + da2.ckWarehouse.warehouseId + '" title="点击查看客户详细信息" class="tablelink">' + da2.ckWarehouse.cname + '</a></cite>\n' +
                            '    </li>\n' +
                            '    <li>\n' +
                            '      <label>出库时间</label>\n' +
                            '      <cite>' + da2.ckWarehouse.cdate + '</cite>\n' +
                            '    </li>\n' +
                            '    <li>\n' +
                            '      <label>出库人</label>\n' +
                            '      <cite>' + da2.ckWarehouse.user.uname + '</cite>\n' +
                            '    </li>\n' +
                            '    <li>\n' +
                            '      <label>出库状态</label>\n' +
                            '      <cite>' + sta2 + '</cite>\n' +
                            '    </li>';
                        $("#forminfo").html(str1);
                        let str2 = '';
                        for (let i = 0; i < da2.orderDetailsList.length; i++) {
                            str2 += '<tr>\n' +
                                '            <td>' + (i + 1) + '</td>\n' +
                                '            <td>' + da2.orderDetailsList[i].product.type.brand.brandName + '</td>\n' +
                                '            <td>' + da2.orderDetailsList[i].product.type.typeName + '</td>\n' +
                                '            <td>' + da2.orderDetailsList[i].product.productModel + '</td>\n' +
                                '            <td>' + da2.orderDetailsList[i].purchaseNum + '</td>\n' +
                                '            <td>' + da2.orderDetailsList[i].product.productUnit + '</td>\n' +
                                '            <td>' + da2.orderDetailsList[i].proprice + '</td>\n' +
                                '            <td>' + (da2.orderDetailsList[i].purchaseNum * da2.orderDetailsList[i].proprice) + '</td>\n' +
                                '        </tr>';
                        }
                        $("#orderView").html(str2);
                    },
                    error: function () {
                        alert("查询订单详情失败！")
                    }
                })
            },
            error: function () {
                alert("查询订单详情失败！")
            }
        });
    }

    function getParameter(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = location.search.substr(1).match(reg);
        if (r != null) {
            return (r[2]);
        }
        return null;
    }

</script>
</body>
</html>
